Skip to content

fix: selectedKeys are not present in the collection warning in async case#2648

Merged
jrgarciadev merged 4 commits into
heroui-inc:mainfrom
wingkwong:fix/eng-572
Apr 14, 2024
Merged

fix: selectedKeys are not present in the collection warning in async case#2648
jrgarciadev merged 4 commits into
heroui-inc:mainfrom
wingkwong:fix/eng-572

Conversation

@wingkwong
Copy link
Copy Markdown
Member

@wingkwong wingkwong commented Apr 5, 2024

Closes #2605

📝 Description

  • When isLoading is true, skip checking missing keys since the collection hasn't built yet.
  • Changed isLoading to true in use-pokemon-list.ts by default to avoid cases like false -> true -> false.

⛳️ Current behavior (updates)

Currently when the data is being fetched (isLoading = true), the warning is shown saying defaultSelectedKeys is not in the collection.

🚀 New behavior

  • as mentioned in description

💣 Is this a breaking change (Yes/No):

No

📝 Additional Information

Summary by CodeRabbit

  • Bug Fixes
    • Patched issues in "@nextui-org/use-aria-multiselect" and "@nextui-org/stories-utils" packages to fix a warning about SELECT defaultSelectedKeys.
  • Refactor
    • Enhanced useMultiSelectListState to better handle loading states.
  • Chores
    • Adjusted initial loading state in usePokemonList for improved user experience.

@wingkwong wingkwong requested a review from jrgarciadev as a code owner April 5, 2024 09:25
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 5, 2024

🦋 Changeset detected

Latest commit: 6516161

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@nextui-org/use-aria-multiselect Patch
@nextui-org/stories-utils Patch
@nextui-org/select Patch
@nextui-org/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextui-storybook-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 5, 2024 9:36am

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 5, 2024

@wingkwong is attempting to deploy a commit to the NextUI Inc Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 5, 2024

Warning

Rate Limit Exceeded

@wingkwong has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 21 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between ef900a1 and 6516161.

Walkthrough

The update introduces patches for the @nextui-org/use-aria-multiselect and @nextui-org/stories-utils packages to address a specific issue with the Select component. When using asynchronous items with a defaultSelectedKeys prop, a warning was displayed if those keys weren't present in the initial collection. This was misleading during loading states. The patches ensure that this warning is suppressed when the isLoading prop is true, aligning with the expected behavior of asynchronous loading.

Changes

File(s) Change Summary
.changeset/rare-plums-speak.md Introduced patches for specific packages to address issue #2605.
...hooks/use-aria-multiselect/src/use-multiselect-list-state.ts Extended MultiSelectListProps and updated useMultiSelectListState to account for isLoading.
...utilities/stories-utils/src/hooks/use-pokemon-list.ts Changed the initial isLoading state to true to reflect async loading behavior.

Assessment against linked issues

Objective Addressed Explanation
Suppress warning for defaultSelectedKeys when isLoading is true (#2605)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review Status

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 6da144f and f3b8269.
Files selected for processing (3)
  • .changeset/rare-plums-speak.md (1 hunks)
  • packages/hooks/use-aria-multiselect/src/use-multiselect-list-state.ts (2 hunks)
  • packages/utilities/stories-utils/src/hooks/use-pokemon-list.ts (1 hunks)
Additional comments not posted (3)
packages/utilities/stories-utils/src/hooks/use-pokemon-list.ts (1)

17-17: The change to initialize isLoading as true aligns well with the asynchronous loading behavior, ensuring the UI correctly reflects the loading state upon component mount.

packages/hooks/use-aria-multiselect/src/use-multiselect-list-state.ts (2)

2-8: Extending MultiSelectListProps with AsyncLoadable is a good approach to incorporate asynchronous loading properties into the multi-select list state management.


52-52: The conditional check for props?.isLoading before logging a warning about missingKeys effectively addresses the issue of unnecessary warnings during asynchronous loading.

Comment thread .changeset/rare-plums-speak.md Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Status

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between f3b8269 and ef900a1.
Files selected for processing (1)
  • packages/hooks/use-aria-multiselect/src/use-multiselect-list-state.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/hooks/use-aria-multiselect/src/use-multiselect-list-state.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] - SELECT defaultSelectedKeys Warning selectedKeys are not present in the collection

2 participants